package com.sbpm.crmbpm.client.handlers;

import com.google.gwt.core.client.GWT;
import com.sbpm.crmbpm.client.panels.views.MainView;
import com.sbpm.crmbpm.client.services.CompanyManagement;
import com.sbpm.crmbpm.client.services.CompanyManagementAsync;
import com.sbpm.crmbpm.client.util.SimpleAsyncCallback;
import com.sbpm.crmbpm.shared.data.client.Company;

public class LoadCompanyCallbackInMainView implements LoadCompanyCallback
{

    private static final CompanyManagementAsync companyManagement = GWT.create( CompanyManagement.class );


    private MainView mainView;

    public LoadCompanyCallbackInMainView( MainView mainView )
    {
        this.mainView = mainView;
    }

    @Override
    public void loadCompany( Long companyId )
    {
        companyManagement.findCompanyWithAllAttributes( companyId, new SimpleAsyncCallback< Company >()
        {
            @Override
            public void onSuccess( Company result )
            {
                mainView.loadCompany( result );
            }
        } );
    }
}
